package cn._2dland.net
{
	import cn._2dland.utils.VideoUtils;
	import cn._2dland.video.StreamInfo;
	
	import flash.events.Event;
	import flash.net.URLRequest;

	public class SixRoomsPartLoader extends PartLoader
	{
		public static const SIXROOMS_URL:String = "http://video.acshmily.cn:9000/video/6cn?vid=";

		public function SixRoomsPartLoader() {
			super();
		}

		override public function load(partXml:XML):void {
			super.load(partXml);

			var url:String = SIXROOMS_URL + partXml.vid + "&ran=" + Math.random();
			_loader.load(new URLRequest(url));
		}

		override protected function loadCompleteHandler(e:Event):void {
			var sixXml:XML = new XML(_loader.data);

			if(sixXml == null) {
				_infos.push(new StreamInfo(VideoUtils.DEFAULT_NAME, VideoUtils.DEFAULT_URL, VideoUtils.DEFAULT_DURATION));
			}
			else {
				var info:StreamInfo = new StreamInfo(_partName, sixXml.url, sixXml.dur, _smooth);
				_infos.push(info);
			}
			dispatchEvent(new Event(Event.COMPLETE));
		}
	}
}